package com.example.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * Created by zhangguobao on 16/10/26.
 */
public class ProxyMain {
    public static void main(String[] args) {
        RealSubject realSubject = new RealSubject();
        InvocationHandler invocationHandler = new DynamicSubject(realSubject);
        Class cls = realSubject.getClass();
        for (Class aClass : cls.getInterfaces()) {
            System.out.println("class interface name "+aClass.getName());
        }
        Subject subject = (Subject) Proxy.newProxyInstance(cls.getClassLoader(), cls.getInterfaces(), invocationHandler);
        subject.stringRequest();
    }
}
